package com.dragon.backstage.domain.param.userOnline;

import com.dragon.common.utils.AjaxResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 在线用户模块-踢掉在线用户请求参数
 *
 * @author dragon
 * @version 1.0
 * @date 2024/10/19 20:47
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "在线用户模块-踢掉在线用户请求参数")
public class UserOnlineKickOutParam {

    @Schema(title = "tokenId")
    private String tokenId;

    @Schema(title = "踢人下线方式（1:单端下线 2:全端下线）")
    private Integer kickOutType;


    public static AjaxResult<Void> check(UserOnlineKickOutParam param) {
        if (Objects.isNull(param)) {
            return AjaxResult.failed("请求参数为空");
        }
        if (StringUtils.isBlank(param.getTokenId())) {
            return AjaxResult.failed("tokenId不能为空");
        }
        if (Objects.isNull(param.getKickOutType())) {
            return AjaxResult.failed("踢人下线方式不能为空");
        }
        if (!param.getKickOutType().equals(1) && !param.getKickOutType().equals(2)) {
            return AjaxResult.failed("踢人下线方式只能为1或2");
        }
        return AjaxResult.succeed();
    }

}
